﻿using System;
using SoftwareConsulting.BI11.NumericalMethods.Properties;
using SoftwareConsulting.BI11.Studio.InternalServices;

namespace SoftwareConsulting.BI11.NumericalMethods
{
    public abstract class BINumericalMethodsException : BIException
    {
        protected BINumericalMethodsException(string message, Exception innerException, params object[] msgParams) :
            base(message, innerException, msgParams)
        {
        }
    }

    public class BINotInitializedException : BINumericalMethodsException
    {
        public BINotInitializedException(Exception innerException) :
            base(Resources.BI_EXCEPTION_NOTINITIALIZED, innerException)
        {
        }
    }

    public class BINotSolvedException : BINumericalMethodsException
    {
        public BINotSolvedException(Exception innerException) :
            base(Resources.BI_EXCEPTION_NOTSOLVED, innerException)
        {
        }
    }

    public abstract class BIGeometryException : BINumericalMethodsException
    {
        protected BIGeometryException(string message, Exception innerException, params object[] msgParams) :
            base(message, innerException, msgParams)
        {
        }
    }

    public class BIGeometryCoordinatesCountMismatch : BIGeometryException
    {
        public BIGeometryCoordinatesCountMismatch(int desiredCoordinatesCount, int realCoordinatesCount, Exception innerException) :
            base(string.Format(Resources.BI_EXCEPTION_GEOMETRY_COORDINATES_COUNTMISMATCH, desiredCoordinatesCount.ToString(), realCoordinatesCount.ToString()), innerException)
        {
        }
    }
    
    public class BIGeometryImpossibleCalculateDistanceException : BIGeometryException
    {
        public BIGeometryImpossibleCalculateDistanceException(Exception innerException) :
            base(Resources.BI_EXCEPTION_GEOMETRY_DISTANCE_IMPOSSIBLECALCULATE, innerException)
        {
        }
    }

    public class BIGeometryImpossibleCalculateCenterException : BIGeometryException
    {
        public BIGeometryImpossibleCalculateCenterException(int coordinateIndex, Exception innerException) :
            base(string.Format(Resources.BI_EXCEPTION_GEOMETRY_CENTER_IMPOSSIBLECALCULATE, coordinateIndex), innerException)
        {
        }
    }

    public class BIGeometryDistanceMethodNotDefinedException : BIGeometryException
    {
        public BIGeometryDistanceMethodNotDefinedException(Exception innerException) :
            base(Resources.BI_EXCEPTION_GEOMETRY_DISTANCEMETHODNOTDEFINED, innerException)
        {
        }
    }

    public class BIGeometryIncorrectCoordinateWeightException : BIGeometryException
    {
        public BIGeometryIncorrectCoordinateWeightException(int coordinateIndex, int desiredCoordinateWeight, Exception innerException) :
            base(string.Format(Resources.BI_EXCEPTION_GEOMETRY_COORDINATE_INCORRECTWEIGHT, coordinateIndex.ToString(), desiredCoordinateWeight.ToString()), innerException)
        {
        }
    }

    public class BIGeometryCoordinatesWeightsNotDefinedException : BIGeometryException
    {
        public BIGeometryCoordinatesWeightsNotDefinedException(Exception innerException) :
            base(Resources.BI_EXCEPTION_GEOMETRY_COORDINATES_WEIGHTSNOTDEFINED, innerException)
        {
        }
    }    

    public abstract class BIClassificationException : BINumericalMethodsException
    {
        protected BIClassificationException(string message, Exception innerException, params object[] msgParams) :
            base(message, innerException, msgParams)
        {
        }
    }

    public class BIClassificationMatrixDivergentDimensionsException : BIClassificationException
    {
        public BIClassificationMatrixDivergentDimensionsException(int factDims, int modelDims, Exception innerException) :
            base(string.Format(Resources.BI_EXCEPTION_CLASSIFICATION_MATRIX_DIVERGENTDIMENSIONS, factDims.ToString(), modelDims.ToString()), innerException)
        {
        }
    }       

    public class BIClassificationAttributesCountMismatch : BIClassificationException
    {
        public BIClassificationAttributesCountMismatch(int desiredAttributesCount, int realAttributesCount, Exception innerException) :
            base(string.Format(Resources.BI_EXCEPTION_CLASSIFICATION_ATTRIBUTES_COUNTMISMATCH, desiredAttributesCount.ToString(), realAttributesCount.ToString()), innerException)
        {
        }
    }

    public class BIClassificationAttributesGroupTooShortException : BIClassificationException
    {
        public BIClassificationAttributesGroupTooShortException(int groupIndex, int groupLength, int minimumLength, Exception innerException) :
            base(string.Format(Resources.BI_EXCEPTION_CLASSIFICATION_ATTRIBUTES_GROUP_TOOSHORT, groupIndex.ToString(), groupLength.ToString(), minimumLength.ToString()), innerException)
        {
        }
    }
    
    public class BIClassificationNoClassExamplesException : BIClassificationException
    {
        private int _classIndex;//индекс класса

        /// <summary>
        /// Возвращает индекс класса
        /// </summary>
        public int ClassIndex
        {
            get
            {
                return _classIndex;
            }
        }

        public BIClassificationNoClassExamplesException(int classIndex, Exception innerException) :
            base(string.Format(Resources.BI_EXCEPTION_CLASSIFICATION_CLASS_NOEXAMPLES, classIndex), innerException)
        {
            _classIndex = classIndex;
        }
    }

    public class BIClassificationIncorrectClass : BIClassificationException
    {
        public BIClassificationIncorrectClass(int desiredClass, int realLastClass, Exception innerException) :
            base(string.Format(Resources.BI_EXCEPTION_CLASSIFICATION_CLASS_INCORRECT, desiredClass.ToString(), realLastClass.ToString()), innerException)
        {
        }
    }

    public class BIMatrixIllegalDimensionException : BINumericalMethodsException
    {
        public BIMatrixIllegalDimensionException(Exception innerException) :
            base(Resources.BI_EXCEPTION_MATRIX_ILLEGALDIMENSION, innerException)
        {
        }

        public BIMatrixIllegalDimensionException(string moreInfo, Exception innerException) :
            base(Resources.BI_EXCEPTION_MATRIX_ILLEGALDIMENSION + " " + moreInfo, innerException)
        {
        }
    }

    public class BIMatrixCantBuildLinearEquationsException : BIMatrixIllegalDimensionException
    {
        public BIMatrixCantBuildLinearEquationsException(int matrixRows, int vectorCols, Exception innerException) :
            base(string.Format(Resources.BI_EXCEPTION_MATRIX_CANTBUILDLINEAREQUATIONS, matrixRows.ToString(), vectorCols.ToString()), innerException)
        {
        }
    }

    public class BIMatrixNotSquareException : BIMatrixIllegalDimensionException
    {
        public BIMatrixNotSquareException(int realRows, int realCols, Exception innerException) :
            base(string.Format(Resources.BI_EXCEPTION_MATRIX_NOTSQUARE, realCols.ToString(), realRows.ToString()), innerException)
        {
        }
    }

    public class BIVectorCantAddOrSubtractException : BIMatrixIllegalDimensionException
    {
        public BIVectorCantAddOrSubtractException(int firstCols, int secondCols, Exception innerException) :
            base(string.Format(Resources.BI_EXCEPTION_VECTOR_CANTADDORSUBTRACT, firstCols.ToString(), secondCols.ToString()), innerException)
        {
        }
    }

    public class BIMatrixCantAddOrSubtractException : BIMatrixIllegalDimensionException
    {
        public BIMatrixCantAddOrSubtractException(int firstRows, int firstCols, int secondRows, int secondCols, Exception innerException) :
            base(string.Format(Resources.BI_EXCEPTION_MATRIX_CANTADDORSUBTRACT, firstCols.ToString(), firstRows.ToString(), secondCols.ToString(), secondRows.ToString()), innerException)
        {
        }
    }

    public class BIVectorCantMultiplyMatrixException : BIMatrixIllegalDimensionException
    {
        public BIVectorCantMultiplyMatrixException(int vectorCols, int matrixRows, Exception innerException) :
            base(string.Format(Resources.BI_EXCEPTION_VECTOR_CANTMULTIPLY_MATRIX, vectorCols.ToString(), matrixRows.ToString()), innerException)
        {
        }
    }

    public class BIVectorCantMultiplyVectorException : BIMatrixIllegalDimensionException
    {
        public BIVectorCantMultiplyVectorException(int firstVectorCols, int secondVectorCols, Exception innerException) :
            base(string.Format(Resources.BI_EXCEPTION_VECTOR_CANTMULTIPLY_VECTOR, firstVectorCols.ToString(), secondVectorCols.ToString()), innerException)
        {
        }
    }

    public class BIMatrixCantMultiplyVectorException : BIMatrixIllegalDimensionException
    {
        public BIMatrixCantMultiplyVectorException(int matrixCols, int vectorCols, Exception innerException) :
            base(string.Format(Resources.BI_EXCEPTION_MATRIX_CANTMULTIPLY_VECTOR, matrixCols.ToString(), vectorCols.ToString()), innerException)
        {
        }
    }

    public class BIMatrixCantMultiplyMatrixException : BIMatrixIllegalDimensionException
    {
        public BIMatrixCantMultiplyMatrixException(int firstMatrixCols, int secondMatrixRows, Exception innerException) :
            base(string.Format(Resources.BI_EXCEPTION_MATRIX_CANTMULTIPLY_MATRIX, firstMatrixCols.ToString(), secondMatrixRows.ToString()), innerException)
        {
        }
    }

    public class BIMatrixCantMultiplyTransposedMatrixException : BIMatrixIllegalDimensionException
    {
        public BIMatrixCantMultiplyTransposedMatrixException(int firstMatrixCols, int secondMatrixCols, Exception innerException) :
            base(string.Format(Resources.BI_EXCEPTION_MATRIX_CANTMULTIPLY_MATRIX_TRANSPOSED, firstMatrixCols.ToString(), secondMatrixCols.ToString()), innerException)
        {
        }
    }

    public class BIMatrixCantMultiplySelfTransposedMatrixException : BIMatrixIllegalDimensionException
    {
        public BIMatrixCantMultiplySelfTransposedMatrixException(int firstMatrixRows, int secondMatrixRows, Exception innerException) :
            base(string.Format(Resources.BI_EXCEPTION_MATRIX_CANTMULTIPLY_MATRIX_SELFTRANSPOSED, firstMatrixRows.ToString(), secondMatrixRows.ToString()), innerException)
        {
        }
    }

    public class BIMatrixNonSymmetricComponentsException : BINumericalMethodsException
    {
        public BIMatrixNonSymmetricComponentsException(int rowIndex, int colIndex, double rowColValue, double colRowValue, Exception innerException) :
            base(string.Format(Resources.BI_EXCEPTION_MATRIX_NONSYMMETRICCOMPONENTS, rowIndex, colIndex, rowColValue, colRowValue), innerException)
        {
        }

        public BIMatrixNonSymmetricComponentsException(string moreInfo, Exception innerException) :
            base(Resources.BI_EXCEPTION_MATRIX_NONSYMMETRICCOMPONENTS + " " + moreInfo, innerException)
        {
        }
    }
}
